package com.ruoyi.keep.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.keep.domain.Informisnew;
import com.ruoyi.keep.service.IInformisnewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 通知用户是否读了Controller
 * 
 * @author zqd
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/keep/informisnew")
public class InformisnewController extends BaseController
{
    @Autowired
    private IInformisnewService informisnewService;

    /**
     * 查询通知用户是否读了列表
     */
    @PreAuthorize("@ss.hasPermi('keep:informisnew:list')")
    @GetMapping("/list")
    public TableDataInfo list(Informisnew informisnew)
    {
        startPage();
        List<Informisnew> list = informisnewService.selectInformisnewList(informisnew);
        return getDataTable(list);
    }

    /**
     * 导出通知用户是否读了列表
     */
    @PreAuthorize("@ss.hasPermi('keep:informisnew:export')")
    @Log(title = "通知用户是否读了", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Informisnew informisnew)
    {
        List<Informisnew> list = informisnewService.selectInformisnewList(informisnew);
        ExcelUtil<Informisnew> util = new ExcelUtil<Informisnew>(Informisnew.class);
        util.exportExcel(response, list, "通知用户是否读了数据");
    }

    /**
     * 获取通知用户是否读了详细信息
     */
    @PreAuthorize("@ss.hasPermi('keep:informisnew:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(informisnewService.selectInformisnewById(id));
    }

    /**
     * 新增通知用户是否读了
     */
    @PreAuthorize("@ss.hasPermi('keep:informisnew:add')")
    @Log(title = "通知用户是否读了", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Informisnew informisnew)
    {
        return toAjax(informisnewService.insertInformisnew(informisnew));
    }

    /**
     * 修改通知用户是否读了
     */
    @PreAuthorize("@ss.hasPermi('keep:informisnew:edit')")
    @Log(title = "通知用户是否读了", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody Informisnew informisnew)
    {
        return toAjax(informisnewService.updateInformisnew(informisnew));
    }

    @PreAuthorize("@ss.hasPermi('keep:informisnew:edit')")
    @Log(title = "通知用户是否读了", businessType = BusinessType.UPDATE)
    @PutMapping("/update/del")
    public AjaxResult update(@RequestBody Informisnew informisnew)
    {
        return toAjax(informisnewService.updateInformdel(informisnew));
    }


    /**
     * 删除通知用户是否读了
     */
    @PreAuthorize("@ss.hasPermi('keep:informisnew:remove')")
    @Log(title = "通知用户是否读了", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(informisnewService.deleteInformisnewByIds(ids));
    }
}
